package com.mobilesales.android.activities;

import java.util.List;

import com.mobilesales.android.c2dm.C2DMMessaging;
import com.mobilesales.android.c2dm.NotificationReceiver;

import android.app.ListActivity;
import android.os.Bundle;
import android.os.Handler;

public abstract class ListModelActivity<T> extends ListActivity implements IRefreshable {


	private NotificationReceiver receiver;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		receiver = new NotificationReceiver() {
			@Override
			public void onMessage(String msg) {
				refresh();
			}
		};
		C2DMMessaging.addNotificationReceiver(receiver);
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		if (receiver!=null)
			C2DMMessaging.removeNotificationReceiver(receiver);
	}	
	
	protected void setItemsSource(List<T> source) {}
	protected List<T> getItems() { return null; }
	private Handler handler = new Handler();
	
	protected Handler getHandler() {
		return this.handler;
	}

}
